package com.example.news;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.news.databinding.FragmentDashboardBinding;
import com.example.news.databinding.FragmentHomeBinding;
import com.example.news.databinding.FragmentHomeboardchildBinding;

import java.text.MessageFormat;


public class HomeboardchildFragment extends Fragment {

    private static  final  String ARGUMENT_POSITION="argument_position";
    private FragmentHomeboardchildBinding binding;
    public HomeboardchildFragment() {

    }


    public static HomeboardchildFragment newInstance(int position) {
        HomeboardchildFragment fragment = new HomeboardchildFragment();
        Bundle args=new Bundle();
        args.putInt(ARGUMENT_POSITION,position);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding=FragmentHomeboardchildBinding.inflate(inflater,container,false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (getArguments()!=null){
            int position=getArguments().getInt(ARGUMENT_POSITION);
            switch (position)
            {
                case 0:
                    binding.tvHome.setText(MessageFormat.format("军事新闻",position));
                    break;
                case 1:
                    binding.tvHome.setText(MessageFormat.format("生活新闻",position));
                    break;
                case 2:
                    binding.tvHome.setText(MessageFormat.format("医疗新闻",position));
                    break;
                    case 3:
                    binding.tvHome.setText(MessageFormat.format("财经新闻",position));
                        break;
                    case 4:
                    binding.tvHome.setText(MessageFormat.format("教育新闻",position));
                    break;
            }

        }
    }
}